<?php
/*
* @desc 联系我们控制类
* @author kevin.wang
* @date 2015-01-01 12:00:00
*/
class EdgeController extends Controller
{
	//联系我们首页
	public function actionIndex()
	{
		$model = new Edge;
		$articleName = $model->getArticleList();
		$articleId = Yii::app()->request->getParam("articleId");
		$articleId = empty($articleId)?$articleName[0]['article_id']:$articleId;
		$content = $model->getArticleContent($articleId);
		if(empty($content)){
			throw new ExceptionClass("文章未找到");
		}
		$this->render('index', array(
				'articleId' => $articleId,
				'articleName' => $articleName,
				'content' => $content
			));
	}
	//获取文章内容
	public function actionContent(){
		$data = array('status' => 0, 'body' => array());
		if(!Yii::app()->request->isAjaxRequest){
			$data['status'] = 10002;
			$this->renderJson($data);
		}
		$articleId = Yii::app()->request->getParam("articleId");
		$model = new Edge;
		$content = $model->getArticleContent($articleId);
		if(empty($content)){
			$data['status'] = 10003;
			$this->renderJson($data);
		}
		$data['body']['content'] = htmlspecialchars_decode($content[0]);
		$this->renderJson($data);
	}
}
